package sch.jl.caigou.impl;

import java.util.ArrayList;
import java.util.List;

import jiliang.purchase.demo.PersonObject;
import sch.jl.caigou.dao.PersonDao;

public class personImpl extends DaoImpl<PersonObject> implements PersonDao
{
	
	//登录
	public PersonObject getPerson(String userName,String password)
	{			
		return getInfomation(userName,password);
	}
	
	
	public PersonObject getInfomation(String userName,String password)
	{
		PersonObject PO = new PersonObject();
		
		String sql = "select * from think_yonghu where gonghao = '"+userName+"';";
		//System.out.println(sql);
		
		PO = query(sql);
			
		return PO;
	}
	
	public List<PersonObject> getAllPerson(String keyword)
	{
		List<PersonObject> list = new ArrayList<PersonObject>();
		
		String sql = "select * from think_yonghu where xingming like '%"+keyword+"%' or gonghao like '%"+keyword+"%'";
		//System.out.println(sql);
		
		list = queryForList(sql);
			
		return list;
	}
	
	//更新用户
	public void SetInformation(PersonObject po)
	{
		String sql="update think_yonghu set gonghao='"+po.getGonghao()+"',xingming='"+po.getXingming()+"',js_id='"+po.getJs_id()+"',dw_id='"+po.getDw_id()+"',mima='"+po.getMima()+"',bendidl='"+po.getBendidl()+"',phone='"+po.getPhone()+"' where gonghao='"+po.getGonghao()+"'";
		//System.out.println(sql);
		update(sql);
	}
	
	//删除用户
	public void deleteInfor(String gonghao)
	{
		String sql = "delete from think_yonghu where gonghao = '"+gonghao+"'";
		//System.out.println(sql);
		delete(sql);
	}
	//添加用户
	public void addInformation(PersonObject po)
	{
		String sql="insert into think_yonghu values('"+po.getGonghao()+"','"+po.getXingming()+"','"+po.getJs_id()+"','"+po.getDw_id()+"','"+po.getMima()+"','"+po.getBendidl()+"','"+po.getPhone()+"')";
		//System.out.println(sql);
		insert(sql);
	}

}
